package jeesample.dtos;

import java.text.SimpleDateFormat;

import javax.xml.bind.annotation.XmlAccessType;
import javax.xml.bind.annotation.XmlAccessorType;
import javax.xml.bind.annotation.XmlElement;
import javax.xml.bind.annotation.XmlRootElement;
import javax.xml.bind.annotation.XmlType;

import jeesample.model.Booking;

@XmlRootElement(name = "BookingDTO")
@XmlAccessorType(XmlAccessType.FIELD)
@XmlType(name = "BookingDTO", propOrder = { "bookingId", "roomId", "bookedBy",
		"startTime", "endTime" })
public final class BookingDTO extends DataTransferObject {
	private static final long serialVersionUID = 2L;

	@XmlElement(required = true)
	private String startTime;
	@XmlElement(required = true)
	private String endTime;
	@XmlElement(required = true)
	private String bookedBy;
	@XmlElement(required = true)
	private String roomId;
	@XmlElement(required = true)
	private String bookingId;

	@Override
	public DataTransferObject getChildDTO() {
		return this;
	}

	public BookingDTO() {
	}

	public BookingDTO(Booking booking) {
		bookedBy = booking.getBookedBy();
		roomId = booking.getRoomId();
		bookingId = booking.getBookingId();
		SimpleDateFormat df = new SimpleDateFormat("yyyy-MM-dd");
		startTime = df.format(booking.getStartTime());
		endTime = df.format(booking.getEndTime());
	}

	public String getStartTime() {
		return startTime;
	}

	public void setStartTime(String startTime) {
		this.startTime = startTime;
	}

	public String getEndTime() {
		return endTime;
	}

	public void setEndTime(String endTime) {
		this.endTime = endTime;
	}

	public String getBookedBy() {
		return bookedBy;
	}

	public void setBookedBy(String bookedBy) {
		this.bookedBy = bookedBy;
	}

	public String getRoomId() {
		return roomId;
	}

	public void setRoomId(String roomId) {
		this.roomId = roomId;
	}

	public String getBookingId() {
		return bookingId;
	}

	public void setBookingId(String bookingId) {
		this.bookingId = bookingId;
	}

}